package SudokuViews;

import com.example.sv2.R;

import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.Log;
import android.view.MotionEvent;
import Core.AGEngine;
import Core.AGView;
import Core.Controls.*;

public class RandomView extends AGView {
	
	private RectF _easyLevelRect;
	private RectF _normalLevelRect;
	private RectF _hardLevelRect;
	
	private AGButton _btnBack;
	private AGButton _btnNormal;
	private AGButton _btnHard;

	public RandomView(AGEngine engine) {
		super(engine);
		// TODO Auto-generated constructor stub
		
		_easyLevelRect = new RectF(140, 400, 340, 450);
		_normalLevelRect = new RectF(140, 470, 340, 520);
		_hardLevelRect = new RectF(140, 570, 340, 620);
		
		this._btnBack = new AGButton(engine, R.drawable.btnreturn);
		this._btnBack.rect = new RectF(400,10, 450,60);
		this._btnBack.addClickEvent(new OnBtnBackClick(this));
		this.controls.add(this._btnBack);
		
		this._btnNormal = new AGButton(engine, R.drawable.btnnormal);
		this._btnNormal.rect = new RectF(111,400, 369,463);
		this._btnNormal.addClickEvent(new OnBtnNormalClick(this));
		this.controls.add(this._btnNormal);
		
		this._btnHard = new AGButton(engine, R.drawable.btnhard);
		this._btnHard.rect = new RectF(111,500, 369,563);
		this._btnHard.addClickEvent(new OnBtnHardClick(this));
		this.controls.add(this._btnHard);
	}

	@Override
	public void onUpdate(AGEngine engine) {
		// TODO Auto-generated method stub
	}

	@Override
	public void onRender(AGEngine engine) {
		// TODO Auto-generated method stub
    	Bitmap imgStartLabel = engine.resource.getImage(R.drawable.randommode);
		RectF destRect = new RectF(83, 159, 407, 281); // 324 122
		engine.graphics.drawBitmap(destRect, imgStartLabel, null);
	}

	class OnBtnBackClick implements IAGEventHandler{
		private RandomView view;
		public OnBtnBackClick(RandomView view){
			this.view = view;
		}
		@Override
		public void onHandle(AGControl control) {
			// TODO Auto-generated method stub
			this.view.switchView(new HomeView(this.view.Engine));
		}
	}
	class OnBtnNormalClick implements IAGEventHandler{
		private RandomView view;
		public OnBtnNormalClick(RandomView view){
			this.view = view;
		}
		@Override
		public void onHandle(AGControl control) {
			// TODO Auto-generated method stub
			this.view.switchView(new GameViewV2(this.view.Engine, 2));
		}
	}
	class OnBtnHardClick implements IAGEventHandler{
		private RandomView view;
		public OnBtnHardClick(RandomView view){
			this.view = view;
		}
		@Override
		public void onHandle(AGControl control) {
			// TODO Auto-generated method stub
			this.view.switchView(new GameViewV2(this.view.Engine, 4));
		}
	}
}
